# Contributor: Chloe Kudryavtsev <toast@toastin.space>
# Maintainer: Chloe Kudryavtsev <toast@toastin.space>
pkgname=skim
pkgver=0.8.2
pkgrel=0
pkgdesc="Fuzzy finder in rust"
url="https://github.com/lotabout/skim"
arch="all !s390x !mips !mips64" # limited by rust/cargo
license="MIT"
makedepends="cargo"
options="net"
subpackages="
	$pkgname-doc
	$pkgname-tmux::noarch
	$pkgname-vim-plugin:vim:noarch
	$pkgname-bash-completion:bash:noarch
	$pkgname-zsh-completion:zsh:noarch
	$pkgname-bash-keybinds:bashkey:noarch
	$pkgname-fish-keybinds:fishkey:noarch
	$pkgname-zsh-keybinds:zshkey:noarch
	"
source="skim-$pkgver.tar.gz::https://github.com/lotabout/skim/archive/v$pkgver.tar.gz"

export CARGO_HOME="$srcdir"/cargo

build() {
	cargo build \
		--release \
		--verbose
}

check() {
	cargo test --all \
		--release \
		--verbose
}

package() {
	install -Dm755 target/release/sk bin/sk-tmux -t "$pkgdir"/usr/bin

	install -Dm644 man/man1/sk.1 -t "$pkgdir"/usr/share/man/man1/
	install -Dm644 man/man1/sk-tmux.1 -t "$pkgdir"/usr/share/man/man1/

	install -Dm644 plugin/skim.vim -t "$pkgdir"/usr/share/vim/vimfiles/plugin

	install -Dm644 shell/completion.bash "$pkgdir"/usr/share/bash-completion/completions/sk
	install -Dm644 shell/completion.zsh "$pkgdir"/usr/share/zsh/site-functions/_sk

	install -Dm644 shell/key-bindings.* -t "$pkgdir"/usr/share/"$pkgname"
}

vim() {
	depends=""
	pkgdesc="Vim plugin for $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel vim"

	amove usr/share/vim
}

tmux() {
	depends="bash"
	pkgdesc="tmux launcher for $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel tmux"

	amove usr/bin/sk-tmux
}

bash() {
	depends=""
	pkgdesc="Bash completion for $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel bash-completion"

	amove usr/share/bash-completion/completions
}

zsh() {
	depends=""
	pkgdesc="Zsh completion for $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel zsh"

	amove usr/share/zsh/site-functions
}

bashkey() {
	depends=""
	pkgdesc="Bash key-bindings for $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel bash"

	amove usr/share/skim/key-bindings.bash
}

fishkey() {
	depends=""
	pkgdesc="Fish key-bindings for $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel fish"

	amove usr/share/skim/key-bindings.fish
}

zshkey() {
	depends=""
	pkgdesc="Zsh key-bindings for $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel zsh"

	amove usr/share/skim/key-bindings.zsh
}

sha512sums="1a1baacf04bd1e92c7fed4424ae785a15f80d0386c12ca1ce6066975a0339e8d04fdc01d65513d49a53cc99643865d959065b8a982860e282df547daf001ef40  skim-0.8.2.tar.gz"
